package com.zj.core.ui

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.Gravity
import android.view.View
import android.view.ViewManager
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.zj.core.R
import org.jetbrains.anko.*
import org.jetbrains.anko.custom.ankoView

class TemplateListItemUi(context: Context){
    private var mContext: Context = context
    var tv_parent_name: TextView?=null
    var img_show: ImageView?=null
    var lv_parent_item: LinearLayout?=null
    var list_chil: RecyclerView?=null
    var record_item_parent_view: LinearLayout?=null

    init {
        record_item_parent_view=mContext.linearLayout{
            lparams(width= matchParent,height = wrapContent)
            orientation= LinearLayout.VERTICAL

            lv_parent_item=linearLayout{
                id= R.id.lv_parent_item
                orientation= LinearLayout.HORIZONTAL
                gravity= Gravity.CENTER_VERTICAL

                tv_parent_name=textView{
                    padding=dip(10)
                    text="标题"
                    id= R.id.tv_parent_name
                    textColor=resources.getColor(R.color.colorsBlank)
                }.lparams(width= 0,height = wrapContent){
                    leftMargin=dip(10)
                    weight=1F
                }

                img_show=imageView{
                    image=resources.getDrawable(R.mipmap.record_down_img)
                    id= R.id.tv_show
                }.lparams(width= dip(30),height =dip(30)){

                }
            }.lparams(width= matchParent,height = wrapContent){
                topMargin=dip(5)
                bottomMargin=dip(5)
            }

            textView{
                backgroundColor=resources.getColor(R.color.colorsGray)
            }.lparams(width= matchParent,height = dip(1))

            list_chil=recyclerview{
                visibility= View.GONE
                id= R.id.list_chil
            }.lparams(width= matchParent,height = wrapContent)
        }
    }

    inline fun ViewManager.recyclerview(theme: Int = 0, init: RecyclerView.() -> Unit) : RecyclerView {
        return ankoView({ RecyclerView(it) }, theme, init)
    }
}